
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2249. -- Pku3896 Multiprocessor Scheduling -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2249: Pku3896 Multiprocessor Scheduling</h2><span class=green>Time Limit: </span>10 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>4&nbsp;&nbsp;<span class=green>Solved: </span>4<br>[<a href='submitpage.php?id=2249'>Submit</a>][<a href='problemstatus.php?id=2249'>Status</a>][<a href='bbs.php?id=2249'>Discuss</a>]</center><h2>Description</h2><div class=content><div class="plm"></div>
<div class="ptx" lang="en-US">There are two applications running on a multiprocessor machine. Each application i (i=1,2) consists of N procedures which are numbered from 1 to N and must be executed sequentially (in the order 1,...,N). A procedure will be identified by a pair (i,j), where i=1,2 identifies the application and 1&le;j&le;N represents the index of the procedure in the sequence of procedures of the application i. A procedure (i,j) can only be executed on the processor P(i,j) of the machine and its execution lasts for D(i,j) seconds. We want to schedule the execution of the procedures of the two applications over the processors of the machine in such a way that the time moment when the last procedure finishes its execution (from any of the two applications) is minimum; this time moment is called makespan. We consider that the two applications are available for scheduling starting from the time moment 0. The schedule needs to obey the following rules: <br />
<p style="padding-left: 30px"><br />
once the execution of a procedure (i,j) starts on the processor P(i,j), we cannot interrupt it until the execution of the procedure ends <br />
we cannot execute multiple procedures on the same processor at the same time, but we can execute multiple procedures in parallel on different processors <br />
the execution of the procedure (i,j) (2&le;j&le;N) starts either at the exact time moment tm when the procedure (i,j-1) finishes its execution or at any time moment after tm <br />
if a procedure begins its execution at time moment tm, then it will finish its execution at the time moment tm+D(i,j) <br />
</p>
<br />
</div></div><h2>Input</h2><div class=content><p>Write a program that, given the information regarding the procedures of the two applications, computes the minimum makespan.</p>
<div class="ptx" lang="en-US">The first line of the input file contains the number T of test cases which are described next. The first line of a test case contains the number N (1&le;N&le;300) of procedures composing each of the two applications. Then, N lines follow, describing the first application. The j<sup>th</sup> of these N lines contains two integers, separated by a blank: P(1,j) and D(1,j). After this, other N lines follow, describing the second application. The j<sup>th</sup> of these N lines contains two integers, separated by a blank: P(2,j) and D(2,j). We have 1&le;P(i,j)&le;10 and 1&le;D(i,j)&le;15000 (i=1,2; 1&le;j&le;N). Notice that we may have P(i,j)=P(k,l) &ndash; this implies that the procedures (i,j) and (k,l) cannot be executed during overlapping time intervals (notice also that if i=k this would not matter, as the procedures of the same application must be executed sequentially).</div></div><h2>Output</h2><div class=content><div class="ptx" lang="en-US">The output file must contain exactly T lines with a single number each &ndash; the minimum makespan for the corresponding test from the input file. These answers must be printed in the order in which the test cases are given in the input file (i.e. the i<sup>th</sup> line of the output file contains the answer to the i<sup>th</sup> test case from the input file).</div></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>2 <br />
1 <br />
2 6 <br />
1 10 <br />
3 <br />
2 31 <br />
2 18 <br />
4 15 <br />
2 26 <br />
3 40 <br />
5 16<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata><br />
10 <br />
90<br />
</span></div><h2>HINT</h2>
			<div class=content><p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=Seerc2009'>Seerc2009</a></p></div><center>[<a href='submitpage.php?id=2249'>Submit</a>][<a href='problemstatus.php?id=2249'>Status</a>][<a href='bbs.php?id=2249'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
